package com.naml.c_inputstream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author marin
 * @version 1.0
 * @date 2025/4/22 21:17
 * @desc 演示 FileInputStream 的使用(字节输入流 文件--> 程序)
 */
@SuppressWarnings("all")
public class FileInputStream03 {
    public static void main(String[] args) {
        //单个字节读取，低效率
        FileInputStream fileInputStream = null;
        try {
            String path = "/Users/marin/new3.txt";
            fileInputStream = new FileInputStream(path);
            int readi = 0;
            while ((readi=fileInputStream.read()) !=-1){
                System.out.print((char)readi);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
